package com.agh.portal.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = { "findCoursesByFaculty" })
public class Course {

    @Size(max = 300)
    @NotEmpty
    private String name;

    private Integer startYear;

    @ManyToOne
    private Faculty faculty;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "course")
    private Set<CourseStudent> students = new HashSet<CourseStudent>();

    @OneToMany(cascade = CascadeType.ALL)
    private Set<AghGroup> aghGroups = new HashSet<AghGroup>();
    
    public String toString(){
    	return "Course [ name="+name+", startYear="+startYear+", faculty="+faculty+"]";
    }

}
